/*
 * @(#)SageReaderTest.java $version 2012. 4. 5.
 *
 * Copyright 2012 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package com.mywep.myalimi.batch.sage;

import java.util.Calendar;

import javax.annotation.Resource;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.configuration.JobLocator;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @author 한지웅
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/applicationContext.xml"})
public class SageReaderTest {
	@Autowired
	@Qualifier("syncJobLauncher")
	private JobLauncher syncJobLauncher;

	@Autowired
	@Qualifier("syncJobLauncher")
	private JobLauncher syncJobLauncherSde;

	@Autowired
	@Qualifier("jobRegistry")
	private JobLocator jobLocator;

	@Resource(name = "sageJob")
	private Job sageJob;

	@Resource(name = "sdeJob")
	private Job sdeJob;
	//	@Autowired
	//	private SageReader sageReader;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * Test method for {@link com.mywep.myalimi.sage.SageReader#afterPropertiesSet()}.
	 */

	/**
	 * Test method for {@link com.mywep.myalimi.batch.sage.SageReader#read()}.
	 * @throws Exception 
	 * @throws NonTransientResourceException 
	 * @throws ParseException 
	 * @throws UnexpectedInputException 
	 */
	//	@Test
	public void testRead() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
		JobParametersBuilder builderSage = new JobParametersBuilder();
		builderSage.addString("sageJob", Calendar.getInstance().toString().substring(0, 100));
		syncJobLauncher.run(sageJob, builderSage.toJobParameters());
	}

	@Test
	public void testRead1() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {

		JobParametersBuilder builderSde = new JobParametersBuilder();
		builderSde.addString("sdeJob", Calendar.getInstance().toString().substring(0, 100));
		syncJobLauncherSde.run(sdeJob, builderSde.toJobParameters());

	}
	
	//	@Test
	public void test() {
		Calendar b = Calendar.getInstance();
		System.out.println(b.getTime());
		b.add(Calendar.DAY_OF_MONTH, -7);
		System.out.println(b.getTime());
	}


}
